//
//  ByUIOrderEvaluateVC.m
//  itboye_shop_ios
//
//  Created by mc on 17/2/9.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByUIOrderEvaluateVC.h"
//Cell
#import "ByCellOrderEvaluateFirst.h"
#import "ByCellOrderEvaluateSecond.h"
#import "ByCellOrderDetailAddPhoto.h"

@interface ByUIOrderEvaluateVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;
@end

@implementation ByUIOrderEvaluateVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"发表评价";
    [self addBYItemviews:@[@"发布"] mode:ByNavigationItemModeText position:ByNavigationItemPositionModeRight];
    [self initTableview];
    [self addLeftBackBarButtonItem];
}

#pragma mark ---创建视图
- (void)initTableview{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:UITableViewStyleGrouped];
    [self.view addSubview:_tableView];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    _tableView.delegate = self;
    _tableView.dataSource = self;

}

#pragma mark ---UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.model.items.count + 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section < self.model.items.count) {
        return 2;
    }else
        return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section < self.model.items.count) {
        if (indexPath.row == 0) {
            ByCellOrderEvaluateFirst *firstCell = [ByCellOrderEvaluateFirst cellWithTableView:tableView];
            ByModelOrderListItemProduct *pro_model = self.model.items[indexPath.row];
            firstCell.model = pro_model;
            return firstCell;

        }
        else{
            ByCellOrderDetailAddPhoto *cell = [ByCellOrderDetailAddPhoto cellWithTableView:tableView];
            cell.addPhotoBlock = ^(NSMutableArray *imgAry){
                NSLog(@"%@",imgAry);
            };
            return cell;
        }

      }
    else{
        ByCellOrderEvaluateSecond *secondCell = [[ByCellOrderEvaluateSecond alloc] init];
        secondCell.msxfRatingStar.tap =^(NSInteger star){
//            self.model.score1 = [NSString stringWithFormat:@"%ld", star];
            //[ByCoreToolAlert alert:[NSString stringWithFormat:@"描述相符%ld星", star]];
        };
        secondCell.wlfwRatingStar.tap =^(NSInteger star){
//            self.model.score2 = [NSString stringWithFormat:@"%ld", star];
            //[ByCoreToolAlert alert:[NSString stringWithFormat:@"物流服务%ld星", star]];
        };
        secondCell.zstdRatingStar.tap =^(NSInteger star){
//            self.model.score3 = [NSString stringWithFormat:@"%ld", star];
            //[ByCoreToolAlert alert:[NSString stringWithFormat:@"赠送态度%ld星", star]];
        };

        return secondCell;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.0001;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section < self.model.items.count) {
        if (indexPath.row == 0) {
            return 55 + 80;

        }
        else{
            return (SCREEN_WIDTH - 20 - 10)/3 + 20;
        }
    }
    else
        return 80 + 35;
}

@end
